<?php
use common\components\widgets\Datetimepicker;
Datetimepicker::widget(['format'=>'Y-m-d',]);
use doumiaoduo\layer\LayerAsset;

LayerAsset::register($this);
?>
<?= $form ?>
<?php if(!empty($model) && empty($model->card_id)):?>
   <!-- <div class="yx-clear">
        <div style="padding-left: 20%">
        <?php // Yii\helpers\Html::buttonInput('生成卡号',['class'=>'btn yx-radius2 yx-d-card yx-bg94d5a2','style'=>'margin:0','id'=>'createCard','data'=>['url'=>\common\components\helpers\Fun::url(['customer/card','id'=>\Yii::$app->request->get('id')])]])?>
        </div>
    </div>-->

<?php endif;?>
<?php if(!empty($row->user)):?>
    <div class="yx-clear">
        <label class="zx-label">会员等级</label>
        <div class="zx-field-floatl">
            <?=$row->user->name?>
        </div>
    </div>
<?php endif;?>

<?php
$js = <<<JS

if($('#customer-check_book').val()=='1'){
    $('#customer-qrcode').focus();
}
$(document).on('click','#createCard',function(){
    var url = $(this).data('url');
    $.post(url,{ajax:'createCard'},function(data){
       $('#customer-card_id').val(data);
    },"json");
});

/*$('#customer-qrcode').blur(function(){
    if($('#customer-check_book').val()=='1'&&$('#customer-qrcode').val()==''){
        $(this).foucs()
        $('#customer-qrcode').focus();
    }
});*/

JS;
$this->registerJs($js);
?>